<%@ page contentType="text/html;charset=utf-8" language="java"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<html:html>
<head>
		<META http-equiv=Content-Type content="text/html; charset=utf-8">
		<LINK href="../styles/stylewang.css"  type=text/css rel=stylesheet>
		<LINK href="xtree.css"  type=text/css rel=stylesheet>
		<style type="text/css"></style>
		<script language=javascript>
			function showFilePath(path){
				
				top.B.Child.document.getElementById("fileframe").setAttribute("src","path/"+path+"?sort=dd");
			}
		</script>
		<title>CGProject</title>
		<html:base/>
</head>

<%String id = (String)request.getAttribute("ID");%>
<%String taskId = (String)request.getAttribute("TaskID");%>
<body onLoad="showFilePath('<%=request.getAttribute("path")%>');">
<table border="0" width="99%" cellspacing="0" id="table6" height="59">
  <tr>
    <td colspan="7" id="onlybt">&nbsp; <b><bean:message key="make"/>&nbsp;<font color="#990000">
      <bean:write name="Make" property="makeName"/>
    </font><bean:message key="make.information"/></b> </td>
  </tr>
  <logic:equal name="NoTask" value="false">
    <tr>
      <td id="leftcenter"><b>&nbsp;<bean:message key="taskname"/></b></td>
      <td  id="leftcenter"><b>&nbsp;<bean:message key="producer"/></b></td>
      <td  id="leftcenter"><b>&nbsp;<bean:message key="make.status"/></b></td>
      <td  id="leftcenter"><b>&nbsp;<bean:message key="expectedhours"/></b></td>
      <td  id="rightcenter"><b><font face="Verdana">&nbsp; </font></b></td>
    </tr>
  </logic:equal>
  <logic:equal name="NoTask" value="True">
    <tr>
      <td id="leftbottom">&nbsp;<font color="#990000"><bean:message key="task.notask"/></font></td>
      <td id="rightbottom"> 　</td>
    </tr>
  </logic:equal>
  <logic:iterate id="element" name="Tasks">
    <logic:equal name="element" property="taskId" value="<%=taskId%>">
      <html:form action="/modTask">
        <html:hidden property="id"/>
        <tr>
          <td  id="leftcenter">
              <html:text property="name" style="font-size: 11px"/></td>
         
          <logic:equal name="Flag"  value="able">
            <td id="leftcenter">
                <html:select property="reguser" style="border:1px solid #C0C0C0; font-family: Tahoma; font-size: 11px">
                  <html:option value=""></html:option>
                  <html:options  collection="Regusers"
							   property="regUserId"
							   labelProperty="regName"/>
                </html:select></td>
          </logic:equal>
          <logic:equal name="Flag" value="disable">
            <td  id="leftcenter">
                <html:select property="reguser" disabled="true" style="border:1px solid #C0C0C0; font-family: Tahoma; font-size: 11px">
                  <html:option value=""></html:option>
                  <html:options  collection="Regusers"
							   property="regUserId"
							   labelProperty="regName"/>
              </html:select></td>
          </logic:equal>
          <td id="leftcenter">
              <script language=javascript>
			var s=top.changeColor("<bean:write name="element" property="status.statusDisplay"/>");
			document.write(s);
		</script>&nbsp;
          </td>
          <td id="leftcenter">
              <html:text property="expectHours" size="5" style="font-size: 11px"/></td>
          <td  rowspan="2" id="rightcenter">&nbsp;
              <input type="button" value="<bean:message key="basicmodify"/>" name="B2" style="font-family: Tahoma; font-size: 11px" onClick="submitModTask()">
            &nbsp;&nbsp;</td>
        </tr>
        <tr>
        	<td id= "rightcenter" height="50">
        		<bean:message key="description"/>
        	</td>
        	 <td colspan="3" id="rightcenter">
              <html:text property="description"  style="font-size: 11px"/></td>
          
        </tr>
      </html:form>
    </logic:equal>
    <logic:notEqual name="element" property="taskId" value="<%=taskId%>">
      <tr>
        <td  id="leftcenter">
            <bean:write name="element" property="taskName"/></td>
        <td  id="leftcenter">
            <logic:notEmpty name="element" property="reguser">
              <bean:write name="element" property="reguser.regName"/>
            </logic:notEmpty><br></td>
        <td id="leftcenter">
          <script language=javascript>
			var s=top.changeColor("<bean:write name="element" property="status.statusDisplay"/>");
			document.write(s);
		</script>&nbsp;</td>
        <td  id="leftcenter">
            <bean:write name="element" property="exceptHours"/></td>
        <td  id="rightcenter">
            <logic:notEmpty name="Manage">
              <html:link page="/makeIndex.do" paramId="taskId" paramName="element" paramProperty="taskId">[<bean:message key="basicmodify"/>]</html:link>
               <a href="../del.do?FatherType=Make&FatherId=<%=id%>&Type=Task&Id=<bean:write name="element" property="taskId"/>" onclick="return   confirm('ConfirmDelete')">[<bean:message key="delete"/>]</a> </logic:notEmpty>
        </td>
      </tr>
      <tr>
      	<td colspan="5" id="rightcenter">
           		<b><bean:message key="description"/><b>
            </td>
      </tr>
      <tr>
      	<td colspan="5" id="rightcenter">
            <bean:write name="element" property="taskDescription"/>&nbsp;
            </td>
      </tr>
      <tr>
      	<td  colspan="5" id="tdtop">
      	</td>
      </tr>
   
    </logic:notEqual>
  </logic:iterate>
  <tr><td id="tdtop" colspan="6">&nbsp;</td></tr>
</table>
<%if (taskId==null || taskId=="")
{ %>
<logic:notEmpty name="Manage">

<html:form action="/addTask">
<html:hidden property="id" value="<%=id%>"/>
<table border="0" cellspacing="0" id="tabletable" cellpadding="0" width="99%">
	<tr>
		<td width="10%" id="btleftbian">&nbsp;<font color="#990000"><bean:message key="task.addtask"/></font>
		</td>
		<td id="btcenterbian"><bean:message key="taskname"/></td>
		<td width="35%" id="btcenterbian"><bean:message key="description"/></td>
		<td width="20%" id="btcenterbian"><bean:message key="producer"/></td>		
		<td width="20%" id="btrightbian"><bean:message key="expectedhours"/></td>
	</tr>
	<tbody id="tbDetailUsed">
	<tr>
		<td width="10%" id="leftcenter" ><input type="checkbox"  disabled name="record_select" ></td>
		<td  width="15%" id="leftcenter">
		<html:text property="name" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/></td>
		<td width="35%" id="leftcenter">
		<html:text property="dexcription" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/></td>
		<td width="20%"  id="leftcenter">
		<html:select property="reguser" style="border:1px solid #C0C0C0; font-family: Tahoma; font-size: 11px">
				<html:option value=""></html:option>
				<html:options  collection="Regusers"
							   property="regUserId"
							   labelProperty="regName"/>
			</html:select></td>
		<td width="20%" id="rightcenter">
		<html:text property="expectHours" size="5" style="border:1px solid #FFFFFF; "/></td>
	</tr>	
	
	</tbody>
	
	<tbody>
	<tr><td>
	<table id="tbDetailPrepare" style="display:none" cellspacing="0" cellpadding="0">
		<tr>
			<td  width="10%" id="leftcenter" ><input type="checkbox"  name="record_select" ></td>
			<td width="15%" id="leftcenter">
			<html:text property="name" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/></td>
			<td width="35%" id="leftcenter">
			<html:text property="dexcription" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/></td>
			<td width="20%" id="leftcenter">
			<html:select property="reguser" style="border:1px solid #C0C0C0; font-family: Tahoma; font-size: 11px">
					<html:option value=""></html:option>
					<html:options  collection="Regusers"
								   property="regUserId"
								   labelProperty="regName"/>
				</html:select></td>
			<td width="20%" id="rightcenter">
			<html:text property="expectHours" style="border:1px solid #FFFFFF; "/></td>
		</tr>	

	</table>
	
	</td></tr>
	</tbody>
	<tr>
			<td width="100%" id="rightbottom" colspan="5">
			<input type="button" value='<bean:message key="submit"/>' name="B1" style="font-family: Tahoma; font-size: 11px" onClick="submitAddTask()">
			&nbsp;&nbsp;&nbsp;&nbsp;
			
		</tr>
	</table>

	


</html:form>

</logic:notEmpty>
<%} %>
</body>
</html:html>
<script language="javascript">
function submitModTask()
{
	if(document.modTaskForm.name.value=="")
	{
		alert("Please input TaskName");
		return;
	}	
	document.modTaskForm.submit();
}



function submitAddTask()
{
	var counter=tbDetailUsed.rows;
	var wrong_counter1=0;
	var wrong_counter2=0;
	for(var i=0;i<counter.length;i++)
	{
		if(document.addTaskForm.name[i].value=="")
		{
			alert("Please input "+(i+1)+"'s name");
			wrong_counter1++;
			break;
		}
	}
	for(var j=0;j<counter.length;j++)
	{
		for(var k=j;k<counter.length;k++)
		{
			if(document.addTaskForm.name[j].value==document.addTaskForm.name[k].value&&j!=k&&wrong_counter1==0)
			{
				alert(""+(j+1)+" and "+(k+1)+" cannot be the same name");
				wrong_counter2++;
				break;
			}

		}
	}
	if(wrong_counter1!=0||wrong_counter2!=0)
	{
		return;
	}
	document.addTaskForm.submit();
}

function addDetailProcess(afterRowIndex)		//增加明细
{
	
	
	var alltbDetailUsed = document.all("tbDetailUsed").rows;
	
	var theFirstSelectedDetail;
	if (afterRowIndex==null)
	{
	  theFirstSelectedDetail=alltbDetailUsed.length-2;
	}
	else theFirstSelectedDetail=afterRowIndex;
	var newRow = document.all("tbDetailPrepare").rows[0].cloneNode(true);
	var desRow = alltbDetailUsed[theFirstSelectedDetail+1];
//		desRow.parentElement.insertBefore(newRow,desRow );
	desRow.parentElement.appendChild(newRow);
	
	return alltbDetailUsed.length;
}

function delDetailProcess()						//删除明细
{
	var tag="";
	var alltbDetailUsed = document.all("tbDetailUsed").rows;
	for(var ii=0;ii<alltbDetailUsed.length;ii++)
	{
		
		if (alltbDetailUsed[ii].all("record_select").checked==true)
		{
			tag="true";
			break;		
		}
		else
		{
			tag="false";
		}
	}
	if(tag=="false")
	{
		alert("Please select a clause");
	}
	else
	{
		for(var i=0;i<alltbDetailUsed.length;i++)
		{
			if (alltbDetailUsed[i].all("record_select").checked==true)
			{
				document.all("tbDetailUsed").deleteRow(i);
				i=i-1;
			}
		}
	}
}

</script>
